﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CardsServer.Tools
{
    public class RegularClass
    {
        /// <summary>
        /// 正则验证
        /// </summary>
        /// <param name="value">待验证字符串</param>
        /// <param name="Regex">正则表达式</param>
        /// <returns>布尔值验证结果</returns>
        public static bool validate(string value, string Regex)
        {
            if (string.IsNullOrEmpty(value))
            {
                return false;

            }

            if (string.IsNullOrEmpty(Regex))
            {
                return false;

            }

            String Estring = Regex;
            String Vstring = value.ToString();

            System.Text.RegularExpressions.RegexOptions op;
            op = System.Text.RegularExpressions.RegexOptions.IgnoreCase;//不区分大小写

            System.Text.RegularExpressions.Regex obj;
            obj = new System.Text.RegularExpressions.Regex(Estring, op);

            bool b = obj.IsMatch(Vstring);

            return b;
        }
    }
}
